import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
// import locale from 'element-ui/lib/locale/lang/en' // lang i18n

import '@/styles/index.scss' // global css

import App from './App'
import store from './store'
import router from './router'
import i18n from '@/lang/index'

import '@/icons' // icon
import '@/permission' // permission control

// 自定义指令
import { imgerr } from '@/directives'
Vue.directive('imgerr', imgerr)

// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)
Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value)
})

import myComponent from '@/components'
Vue.use(myComponent)

// 混入
import { checkPermMixin } from '@/mixin/index'
Vue.mixin(checkPermMixin)
// 过滤器
// Vue.filter('formData', val => {
//   // console.log(val)
//   return val.split('T')[0]
// })
// 多个引入过滤器
import * as filters from '@/filters'
Object.keys(filters).forEach(filterName => {
  return Vue.filter(filterName, filters[filterName])
})

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  i18n,
  render: h => h(App)
})
